import api from './index'

export const streamApi = {
  // 获取直播流列表
  async getStreams(params = {}) {
    const queryString = new URLSearchParams(params).toString()
    const response = await api.get(`/streams/list?${queryString}`)
    return response
  },

  // 获取单个直播流详情
  async getStream(id) {
    const response = await api.get(`/streams/${id}`)
    return response
  },

  // 创建直播流
  async createStream(streamData) {
    const response = await api.post('/streams/', streamData)
    return response
  },

  // 更新直播流
  async updateStream(id, streamData) {
    const response = await api.put(`/streams/${id}`, streamData)
    return response
  },

  // 删除直播流
  async deleteStream(id) {
    const response = await api.delete(`/streams/${id}`)
    return response
  },

  // 启动直播流
  async startStream(id) {
    const response = await api.post(`/streams/${id}/start`)
    return response
  },

  // 停止直播流
  async stopStream(id) {
    const response = await api.post(`/streams/${id}/stop`)
    return response
  }
}

export default streamApi